package com.grep.web.manager;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import com.grep.extra.dao.impl.ContentParseFieldDao;
import com.grep.extra.dao.impl.TaskDAOSQL;
import com.grep.extra.dao.impl.WebSiteDAOSQL;
import com.grep.extra.factory.data.impl.ContentParseField;
import com.grep.extra.factory.data.impl.SiteUrl;
import com.grep.extra.factory.data.impl.TaskUrl;

public class FenYe {

	// 每页显示数据
	private int pagesize = 2;

	public List<SiteUrl> getWebSiteFenYeData(int index) {

		WebSiteDAOSQL website = new WebSiteDAOSQL();

		if (1 == index) {
			index = 0;
		} else {
			index = index - 1;
		}

		int start = index * pagesize;

		List<SiteUrl> list = website.getWebSites(start, pagesize);

		return list;
	}

	public List<TaskUrl> getTaskFenYeData(String siteid, int start, int pagenum) {

		if (1 == start) {
			start = 0;
		} else {
			start = start - 1;
		}

		int index = start * pagenum;

		List<TaskUrl> listTaksUrl = new ArrayList<TaskUrl>();

		TaskDAOSQL taskDao = new TaskDAOSQL();

		listTaksUrl = taskDao.getTaskbySiteID(siteid, index, pagenum);

		return listTaksUrl;
	}

	public List<TaskUrl> getTaskUrlFenYeData(String siteid, int start, int pagenum) {

		if (1 == start) {
			start = 0;
		} else {
			start = start - 1;
		}

		int index = start * pagenum;

		List<TaskUrl> listTaksUrl = new ArrayList<TaskUrl>();

		TaskDAOSQL taskDao = new TaskDAOSQL();

		listTaksUrl = taskDao.getTaskUrlsByTaskId(siteid, index, pagenum);

		return listTaksUrl;
	}
	
	
	public List<ContentParseField> getTaskZhiBiaoFenYeData(String contentParseID, int start, int pagenum) {

		if (1 == start) {
			start = 0;
		} else {
			start = start - 1;
		}

		int index = start * pagenum;

		List<ContentParseField> listTaksUrl = new ArrayList<ContentParseField>();
		
		ContentParseFieldDao cpfd = new ContentParseFieldDao();

		listTaksUrl =  cpfd.getFieldForContentParseID(contentParseID, index, pagenum);

		return listTaksUrl;
	}

	public int getPagesize() {
		return pagesize;
	}

	public void setPagesize(int pagesize) {
		this.pagesize = pagesize;
	}
}
